﻿Imports Equipment.DataAccess

Public Class MeasureWrapper

#Region "Properties"

    Public _name As String
    Public Property MeasureName As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property

    Public _type As String
    Public Property Type As String
        Get
            Return _type
        End Get
        Set(ByVal value As String)
            _type = value
        End Set
    End Property

    Public _value As String
    Public Property Value As String
        Get
            Return _value
        End Get
        Set(ByVal value As String)
            _value = value
        End Set
    End Property

    Public _range As String
    Public Property Range As String
        Get
            Return _range
        End Get
        Set(ByVal value As String)
            _range = value
        End Set
    End Property

#End Region

    Public Shared Function ConvertToWrapperList(ByVal measureSource As IEnumerable(Of Equipment.DataAccess.RequirementMeasure)) As List(Of MeasureWrapper)
        Dim wrapperList As New List(Of MeasureWrapper)

        For Each m In measureSource
            Dim w As New MeasureWrapper
            Dim type As MeasureType = CType(m.MeasureType, MeasureType)

            w.MeasureName = m.MeasureDescription
            w.Type = type.ToString()
            w.Value = m.LookupValue
            If type = MeasureType.Integer Then
                w.Range = m.IntegerMin & "\" & m.IntegerMax
            ElseIf type = MeasureType.Decimal Then
                w.Range = m.DecimalMin & "\" & m.DecimalMax
            Else
                w.Range = m.OptimalLookupValue
            End If
            wrapperList.Add(w)
        Next

        Return wrapperList
    End Function
End Class
